﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 求子字符串出现的次数
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 0;
            int count = 0;
            string test = "redaabredjjkreddd";

            while (test.IndexOf("red", i) >= 0)
            {
                i = test.IndexOf("red", i) + 1;
                count++;

                Console.WriteLine("i={0},count={1}", i, count);
            }

            Console.Read();
        }
    }
}
